package com.example.zhuyu.login.module.mvp.model;

import com.example.zhuyu.basemvp.base.BaseModel;
import com.example.zhuyu.basemvp.di.scope.ActivityScope;
import com.example.zhuyu.basemvp.http.BaseResponse;
import com.example.zhuyu.basemvp.http.IRetrofitManager;
import com.example.zhuyu.basemvp.http.RxSchedulersHelper;
import com.example.zhuyu.login.module.api.LoginApi;
import com.example.zhuyu.login.module.mvp.contract.LoginContract;
import com.example.zhuyu.login.module.mvp.entity.response.LoginResponse;

import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @author zhuyu
 * @date 2019/2/20
 * @desc
 */

@ActivityScope
public class LoginModel extends BaseModel implements LoginContract.Model{


    @Inject
    public LoginModel(IRetrofitManager mRetrofitManager) {
        super(mRetrofitManager);
    }

    @Override
    public void onDestroy() {

    }


    @Override
    public Observable<BaseResponse<LoginResponse>> login(Map<String, String> map) {
        return mRetrofitManager.obtainRetrofitService(LoginApi.class)
                .login(map)
                .compose(RxSchedulersHelper.<BaseResponse<LoginResponse>>io_main());
    }
}
